<template>
  <div class="page nav">
    <div class="info">
      <img class="logo" src="../../assets/image/log.png" alt="" width="100%">
      <div class="info_title">
        您好！{{name}}
      </div>
      <div class="info_set">
        <span @click="putpassbox = true">修改密码</span>｜<span @click="tologin">注销</span>
      </div>
    </div>
    <el-menu
      v-if="xs"
      :default-active="defaultActive"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      @select='routerpath'
      >
      <el-menu-item index="1">
        <!-- <i class="el-icon-menu"></i> -->
        <span class="menutitle" slot="title">系统首页</span>
      </el-menu-item>
      <el-menu-item v-if="cns" index="2">
        <!-- <i class="el-icon-setting"></i> -->
        <span class="menutitle"  slot="title">承诺书</span>
      </el-menu-item>
      <el-menu-item index="3" v-if="hasChose">
        <!-- <i class="el-icon-setting"></i> -->
        <span class="menutitle" slot="title">作者信息</span>
      </el-menu-item>
      <el-menu-item index="4" v-if="hasChose">
        <!-- <i class="el-icon-setting"></i> -->
        <span class="menutitle" slot="title">素质测评</span>
      </el-menu-item>
      <el-submenu index="5" v-if="isState4">
        <template slot="title">
          <span style="text-aligin:right" class="menutitle">项目信息</span>
        </template>
        <el-menu-item index="5-1">
          <span class="" slot="title">研究项目(必填)</span>
        </el-menu-item>
        <el-menu-item index="5-2">
          <span class="" slot="title">个人陈述(必填)</span>
        </el-menu-item>
        <el-menu-item index="5-3">
          <span class="" slot="title">辅导教师(必填)</span>
        </el-menu-item>
        <el-menu-item index="5-4">
          <span class="" slot="title">学习成绩(必填)</span>
        </el-menu-item>
        <el-menu-item index="5-5">
          <span class="" slot="title">指导专家(选填)</span>
        </el-menu-item>
      </el-submenu>
      
      <el-menu-item index="6" v-if="yujianshenbaoshu">
        <!-- <i class="el-icon-setting"></i> -->
        <span class="menutitle" slot="title">预检打印申报书</span>
      </el-menu-item>
      <el-menu-item index="7" v-if="shangchuanshenbaoshu">
        <!-- <i class="el-icon-setting"></i> -->
        <span class="menutitle" slot="title">上传盖章申报书</span>
      </el-menu-item>

    </el-menu>

    <el-menu
      v-if="sh"
      :default-active="defaultActive"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      @select='routerpath'
      >
      <el-menu-item index="1">
        <!-- <i class="el-icon-menu"></i> -->
        <span class="menutitle" slot="title">系统首页</span>
      </el-menu-item>
      <el-menu-item index="8">
        <!-- <i class="el-icon-setting"></i> -->
        <span class="menutitle" slot="title">审核汇总</span>
      </el-menu-item>

    </el-menu>
    <el-menu
      v-if="ps"
      :default-active="defaultActive"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      @select='routerpath'
      >
      <el-menu-item index="1">
        <!-- <i class="el-icon-menu"></i> -->
        <span class="menutitle" slot="title">系统首页</span>
      </el-menu-item>
      <el-menu-item index="12" v-if="pscns">
        <!-- <i class="el-icon-setting"></i> -->
        <span class="menutitle" slot="title">承诺书</span>
      </el-menu-item>
      <el-menu-item index="9" v-if="!pscns">
        <!-- <i class="el-icon-setting"></i> -->
        <span class="menutitle" slot="title">在线评审</span>
      </el-menu-item>

    </el-menu>
    <el-menu
      v-if="gl"
      :default-active="defaultActive"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      @select='routerpath'
      >
      <el-menu-item index="1">
        <!-- <i class="el-icon-menu"></i> -->
        <span class="menutitle" slot="title">系统首页</span>
      </el-menu-item>
      <el-menu-item index="10">
        <!-- <i class="el-icon-setting"></i> -->
        <span class="menutitle" slot="title">项目查询</span>
      </el-menu-item>
      <el-menu-item index="13">
        <span class="menutitle" slot="title">账号列表</span>
      </el-menu-item>
      <el-menu-item index="14">
        <span class="menutitle" slot="title">项目导出</span>
      </el-menu-item>
    </el-menu>

    <putpass :show="putpassbox" @close="close"></putpass>
  </div>
</template>

<script type="text/ecmascript-6">
import { routerpush } from "@/function/exportjs.js";
import { navIndex } from "@/function/navIndex/nav.js";
import putpass from "@/components/putpass/";
export default {
  data() {
    return {
      putpassbox: false,
      defaultActive: "1",
      hasChose: false,
      isState4: false,
      type: false,
      cns: true,
      pscns: true,
      yujianshenbaoshu: true,
      shangchuanshenbaoshu: true,
      xs: false,
      ps: false,
      sh: false,
      gl: false,
      name: "申报者"
    };
  },
  components: {
    putpass
  },
  mounted() {
    this.lookurl();
    this.nowIndex();
    this.getuser();
    this.getSession();
    this.cnsStatus()
  },
  methods: {
    cnsStatus() {
      this.$http.get('/common/user/get/accept/state').then(res=> {
        if(res.data.accept === true) {
          this.pscns = false
        }
      })
    },
    close() {
      this.putpassbox = false;
    },
    getuser() {
      let user = JSON.parse(sessionStorage.getItem("user"));
      this.name = user.name;
    },
    lookurl() {
      let usertype = sessionStorage.getItem("usertype");
      switch (usertype) {
        case "1":
          this.xs = true;
          this.ps = false;
          this.sh = false;
          this.gl = false;
          break;
        case "2":
          this.xs = false;
          this.ps = false;
          this.sh = true;
          this.gl = false;
          break;
        case "3":
          this.xs = false;
          this.ps = true;
          this.sh = false;
          this.gl = false;
          break;
        case "4":
          this.xs = false;
          this.ps = false;
          this.sh = false;
          this.gl = true;
          break;
        default:
          break;
      }
    },
    handleClose() {
    },
    handleOpen() {
    },
    routerpath(index, path) {
      routerpush(index, this);
    },
    tologin() {
      sessionStorage.removeItem("usertype");
      sessionStorage.removeItem("chose");
      this.$router.push("/");
    },
    getSession() {
      this.$http.get("/filing/process/info").then(res => {
        // if (res.data.process > 1) {
        //   this.hasChose = true;
        // }
        // if ((res.data.process = 5)) {
        //   this.hasChose = false;
        //   this.type = true;
        // }
        switch (res.data.process) {
          case 1:
            this.hasChose = false;
            this.yujianshenbaoshu = false;
            this.shangchuanshenbaoshu = false;
            // this.cns = false;
            break;
          case 2:
            this.hasChose = true;
            this.cns = false;
            this.yujianshenbaoshu = false;
            this.shangchuanshenbaoshu = false;
            break;
          case 3:
            this.hasChose = true;
            this.cns = false;
            this.yujianshenbaoshu = false;
            this.shangchuanshenbaoshu = false;
            break;
          case 4:
            this.hasChose = true;
            this.isState4 = true;
            this.cns = false;
            this.yujianshenbaoshu = true;
            this.shangchuanshenbaoshu = true;
            break;
          case 5:
            this.hasChose = true;
            this.cns = false;
            this.isState4 = true;
            this.yujianshenbaoshu = true;
            this.shangchuanshenbaoshu = true;
            break;
          case 6:
            this.cns = false;
            this.isState4 = true;
            this.hasChose = true;
            this.yujianshenbaoshu = true;
            this.shangchuanshenbaoshu = true;
            break;
          case 7:
            this.hasChose = false;
            // this.yujianshenbaoshu = false;
            this.shangchuanshenbaoshu = true;
            this.cns = false;
            break;
          case 8:
            this.yujianshenbaoshu = false;
            this.shangchuanshenbaoshu = false;
            this.cns = false;
            this.$alert("项目申报完成！", "提示", {
              confirmButtonText: "确定"
            });
            break;

          default:
            break;
        }
      });
      // if(sessionStorage.getItem('chose') !== null) {
      //   this.hasChose = true
      // } else {
      //   this.hasChose = false
      // }
    },
    nowIndex() {
      let url = this.$route.path;
      navIndex(url, this);
    }
  },
  watch: {
    $route: ["getSession", "nowIndex",'cnsStatus']
  }
};
</script>

<style scoped lang="scss">
@import "./index.scss";
</style>
